3. modularize session context - #2190
Conversation
|
Macroscope skipped reviewing this pull request. Per-review cost limit exceeded (workspace setting). This review would cost an estimated $11.11, which exceeds your per-review limit of $10.00. The top 3 files driving up this estimate:
Tip To get this pull request reviewed, you can:
|
d68c7af to
827d1d4
Compare
Prime Agent performance — completedPR Overall: 0 regressed · 0 improved · 17 no clear change.
Python runtime
Sandbox cost: ~$0.0886 — no inference calls. Methodology and samplesMain resolved at 2026-09-11T19:29:33.532386+00:00. Harness
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 827d1d4. Configure here.
827d1d4 to
0a9d196
Compare
Refs ENG-5938
Refs ENG-5938
Refs ENG-5938
0a9d196 to
5127774
Compare

This is part of the stack giving Prime Agent session features explicit owners. This PR moves compaction, refinement, and continuation state and cleanup out of AgentSession into focused session modules, while preserving persistence, cancellation, event ordering, public dispatch, and custom-reviewer behavior.
It also fixes two existing CodeQL findings surfaced during review: Codex model URL normalization now takes linear time, and Python skill import names are passed as data instead of inserted into executable Python source. The unused SerializedBackgroundPlanResult facade re-export is removed; its owning module retains the type.
Rebased on main at 5255a6b. Repository checks pass at this PR head, and 31 focused bootstrap and model-discovery regressions pass. Earlier compaction/refinement coverage is recorded in the cleanup issue; GitHub checks and benchmarks must finish on the updated commits. Macroscope's full correctness review is still blocked by its per-review cost limit.
Stacked on #2185; tracks ENG-5938.
Note
Modularize
AgentSessioninto compaction, continuation, and refinement coordinatorsSessionCompaction,SessionContinuation,SessionRefinement,AutoRefinement, andRefinementExecutionfromAgentSessionin agent-session.ts, with each coordinator owning its state, abort controllers, and lifecycle via host callback interfaces.importlibarguments instead of interpolating into Python source, and fixes Codex model URL trailing-slash normalization in model-registry.ts.AgentSession, inserting a custom digest message when the newest stored or retained digest differs.SerializedInternals,SessionInternals, etc.) are restructured to nested refinement/compaction/continuation components; out-of-tree consumers relying on flat_compactionor_refinementfields onAgentSessionwill break. Compaction and refinement status now read from coordinator state instead of removed in-class fields.Macroscope summarized 5127774.
Note
Medium Risk
Large refactor of compaction, continuation, and refinement orchestration in the core agent loop; behavior is intended to be preserved but regressions would affect session persistence, cancellation, and headless idle semantics.
Overview
Modularizes session context by moving compaction, post-compaction continuation, and harness refinement out of
AgentSessioninto dedicatedsession/*coordinators wired through typed host callbacks. Public entry points (compact,refine, hostcompact.*/refine.*, events, abort/disposal) delegate to the new owners while preserving the documented lifecycle rules (disconnect/reconnect ordering, continuation settlement, serialized refine checkpoints, overflow/threshold behavior).Compaction splits into
SessionCompaction(pending requests, automatic/manual runs, overflow recovery, outcome messages) andperformSessionCompactionincompaction-execution.ts(extensions, semantic-edge accounting, transcript rebuild). Continuation moves toSessionContinuationwith one-shot settlement and commit-fence gating beforeagent.continue(). Refinement consolidates inSessionRefinementwithAutoRefinementand execution helpers for planning/apply, serialized background plans, disposal drains, and branch invalidation. README adds a session-context ownership table and test pointers.Hardening: Codex model URL normalization drops regex trailing-slash stripping for a linear scan, and kernel bootstrap checks Python skill imports via
importlib.import_module(sys.argv[1])instead of embedding names in-csource.Reviewed by Cursor Bugbot for commit 5127774. Bugbot is set up for automated code reviews on this repo. Configure here.